﻿@{
    ViewData["Title"] = "HyperlinksView";
    Layout = null;
}


<link href="~/libs/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />

<div style="width:420px;height:300px;float:left;margin-left:5px;margin-top:10px;">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">工作站编号</label>
            <div class="layui-input-block">
                <input type="text" id="workStationCode" name="workStationCode" autocomplete="off" class="layui-input" readonly>
            </div>
        </div>

    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">工作站名称</label>
        <div class="layui-input-block">
            <input type="text" id="workStationName" name="workStationName" autocomplete="off" placeholder="工作站名称" lay-verify="required" class="layui-input" readonly>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">工作站地点</label>
        <div class="layui-input-block">
            <input type="text" id="workStationLocations" name="workStationLocations" autocomplete="off" placeholder="工作站地点" lay-verify="required" class="layui-input" readonly>
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label">所在车间</label>
            <div class="layui-input-inline">
                <select name="workshopId" id="workshopId" lay-filter="workshopId" disabled>
                    <option value="0">请选择</option>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label">所属工序</label>
            <div class="layui-input-inline">
                <select name="processId" id="processId" lay-filter="processId " disabled>
                    <option value="0">请选择</option>
                    <option value="1">材料切割</option>
                    <option value="2">成型</option>
                    <option value="3">连接</option>
                    <option value="4">打磨</option>
                    <option value="5">涂漆/上油</option>
                    <option value="6">部件组装</option>
                </select>
            </div>
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" id="remark" name="remark" class="layui-textarea" lay-filter="remark" readonly></textarea>
            </div>
        </div>
    </div>

    <div class="layui-form-item" pane>
        <label class="layui-form-label">是否启用</label>
        <div class="layui-input-block" disabled>
            <input type="radio" name="isNo" id="isNo" value="1" title="是" disabled checked>
            <input type="radio" name="isNo" id="isNo" value="0" title="否" disabled>
        </div>
    </div>
</div>

<div style="width:200px;height:400px;float:revert;margin-left:10px;margin-top:10px;margin-left:580px;">
    <div class="qrcode">
        <img src="" alt="二维码" id="image" style="width:180px;height:180px;" />
    </div>
</div>

<script src="~/libs/layui-v2.5.6/layui/layui.js"></script>
<script src="~/libs/jquery/jquery.js"></script>

<script>

    $(function () {
        //获取车间信息
       getWorkshopList();
       //获取数据
       GetTheData()
    });


    //获取表单数据
    function GetTheData(){
          console.log(@ViewBag.id);
        $.ajax({
            url:'/WorkStation/SpecificData',
            type:'get',
             data: {
                 id: @ViewBag.id
             } ,
             success:function(data){
                console.log(data);
                $('#workStationCode').val(data.workStationCode);
                $('#workStationName').val(data.workStationName);
                $('#workStationLocations').val(data.workStationLocations);
                $('#workshopId').val(data.workshopId);
                 layui.form.render("select");
                $('#processId').val(data.processId);
                 layui.form.render("select");
                $('#remark').val(data.remark);
                $('#isNo').val(data.isNo);
                layui.form.render("radio");
                //$('#image').val(data.image);
                 //$('#image').prop('href',data.image);
                //$('#image').prop('src',data.image);
                $('#image').prop("src","/qrcode/"+ data.image.replace("https://localhost:44376/",""));


            }
        })
    }


    //获取车间信息
    function getWorkshopList() {
           $.ajax({
            url:'/WorkStation/WorkshopSetupsList',
            type:'get',
            async:false,
            success:function(res){
                console.log(res);
                var html = '<option value="0">请选择</option>';
                $.each(res.data,function(i,item){
                    html += '<option value="'+item.id+'" readonly>'+item.workShopName+'</option>';
                })
                $('#workshopId').html(html);
                layui.form.render('select');
            }
        })
    }


    /// 生成随机编号
    function codeRandom(){
        $.ajax({
            url:'/WorkStation/CodeRandom',
            type:'get',
            success:function(res){
                console.log(res);
                $('#workStationCode').val(res.data);
            }
        })
    }

    //返回原页面
    function reset(){
        console.log("返回");
        //在当前iframe => 关闭当前iframe
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }

</script>
